<?php

namespace App\Http\Middleware;

use Closure;
use Overtrue\Socialite\User as SocialiteUser;
use Fideloper\Proxy\TrustProxies as Middleware;

class WechatTestUserInfo extends Middleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = new SocialiteUser([
            'id' => 'oTPnlwVhO4vt8PjQAWNuzCqtTuPI',
            'name' => 'Tortoise',
            'nickname' => 'Tortoise',
            'avatar' => 'http://thirdwx.qlogo.cn/mmopen/vi_32/CztHribbzmYRJkG6vml3S83j2Ymd8q4QUDjL1ial8j5UhDOyUIvCnuPR8D9MibZRiaSkshCWsNbQ4veec6qCOG7DlA/132',
            'email' => null,
            'original' => [
                "openid" => "oTPnlwVhO4vt8PjQAWNuzCqtTuPI",
                "nickname" => "Tortoise",
                "sex" => 1,
                "language" => "zh_CN",
                "city" => "广州",
                "province" => "广东",
                "country" => "中国",
                "headimgurl" => "http://thirdwx.qlogo.cn/mmopen/vi_32/CztHribbzmYRJkG6vml3S83j2Ymd8q4QUDjL1ial8j5UhDOyUIvCnuPR8D9MibZRiaSkshCWsNbQ4veec6qCOG7DlA/132",
                "privilege" => [],
                "unionid" => "oyEgSw37w4vEzqVUON2TucIeOYbk",
            ],
            'provider' => 'WeChat',
        ]);
        session(['wechat.oauth_user.default' => $user]);
        return $next($request);
    }
}
